// pages/activity/pay/paySuccess/paySuccess.js
const app = getApp()
var http = require("../../../../utils/httpUtils")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    dataList: [],
    textarr: '',
    money: '0.00',
    o_id: '692',
    o_activity_type: '5',
    o_type: '0',
    ono: '20201123679340'
  },

  getData: function () {
    var that = this
    // 获取数据
    var urls = app.globalData.SERVER_IP + '/organization/related_recommendations/o_no/' + that.data.ono + '/o_id/' + that.data.o_id
    http.G(urls, {}, (res) => {

      console.log("获取信息", res.result)
      that.setData({
        dataList: res.result.relatedItems
      })

    }, (err) => {
      console.log("获取信息失败")
      console.log(err)
    })

  },
  goShop: function () {
    wx.navigateTo({
      url: '../../../index/index',
    })
  },

  goOrder: function () {
    wx.navigateTo({
      url: '../../../user_center/my_order/my_order',
    })
  },
  goBuy: function (e) {
    console.log("目标购买商品ID：" + e.currentTarget.dataset.sid)
    var that = this
    if(this.data.o_type == 2){
      // 课程
      wx.navigateTo({
        url: '../../../activity/course/course?activityId=' + e.currentTarget.dataset.sid + '&o_id=' + that.data.o_id,
      })
    }else if(this.data.o_type == 0 && this.data.o_activity_type == 5){
      // 促销
      wx.navigateTo({
        url: '../../../activity/promotion/promotion?activityId=' + e.currentTarget.dataset.sid + '&o_id=' + that.data.o_id,
      })
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      money: options.money,
      o_id: options.o_id,
      ono: options.ono,
      o_activity_type: options.o_activity_type,
      o_type: options.o_type,
    })
    this.getData()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    wx.hideShareMenu({})
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})